jQuery.validator.addMethod("mingt", function (value, element, param) {
	return this.optional(element) || value > param;
})

jQuery.validator.addMethod("maxlt", function (value, element, param) {
	return this.optional(element) || value < param;
})

jQuery.validator.addMethod("maxLen", function (value, element, param) {
	return this.optional(element) || value.length < param;
})

//正整数
jQuery.validator.addMethod("posNumber", function (value, element, param) {
	return this.optional(element) || /^\d+(\.\d+)?$/.test(value);
})

//http://开头,必输一个字
jQuery.validator.addMethod("httpUrlNeed", function (value, element) {
	return this.optional(element) || /^http(s)?:/.test(value);
}, "请输入正确的URL地址");

//图片格式
jQuery.validator.addMethod("imageType", function (value, element) {
	return this.optional(element) || /(.*)\.(jpg|bmp|gif|ico|pcx|jpeg|tif|png|raw|tga)$/.test(value.toLowerCase());
}, "请上传格式正确的图片");

//空或者为图片格式
jQuery.validator.addMethod("emptyOrImageType", function (value, element) {
	return this.optional(element) || value == '' || /(.*)\.(jpg|bmp|gif|ico|pcx|jpeg|tif|png|raw|tga)$/.test(value.toLowerCase());
}, "请上传格式正确的图片");

//统一社会信用代码或者组织机构代码
jQuery.validator.addMethod("compCode", function (value, element) {
	return this.optional(element) || /(^91\d{6}[0-9A-HJ-NPQRTUWXY]{10}$)|(^[0-9A-HJ-NPQRTUWXY]{8}-?[0-9A-HJ-NPQRTUWXY]$)/.test(value.toUpperCase());
}, "请输入正确的统一社会信用代码或者组织机构代码");

//手机号码
jQuery.validator.addMethod("mobile", function (value, element) {
	var length = value.length;
	var mobile = /^(1[34578][0-9]{9})$/;
	return this.optional(element) || (length === 11 && mobile.test(value));
}, "请输入正确的手机号码");

//固话号码
jQuery.validator.addMethod("tel", function (value, element) {
	return this.optional(element) || value == '' || /^(0\d{1,3})-\d{7,8}$/.test(value);
}, "请输入正确的固话号码");

//手机或固话
jQuery.validator.addMethod("phone", function (value, element) {
	return this.optional(element) || value == '' || /^(\+86)?1\d{10}$|^(0\d{1,3})-\d{7,8}$/.test(value);
}, "请输入正确的手机或固话号码");

//IP
jQuery.validator.addMethod("ip", function (value, element) {
	return this.optional(element) || value == '' || /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/.test(value);
}, "请输入正确的IP地址");

//邮政编码
jQuery.validator.addMethod("zipcode", function (value, element) {
	return this.optional(element) || value == '' || /^\d{6}$/.test(value);
}, "请输入有效的邮政编码");

//是否相同
jQuery.validator.addMethod("sameAs", function (value, element, param) {
	return this.optional(element) || value == param.val();
});

//是否依赖另一个元素的某个值,如notEmptyDependsOn:'#code','2'，表示#code的值为2时当前元素值不能为空
jQuery.validator.addMethod("notEmptyDependsOn", function (value, element, params) {
	return $(params[0]).val() != params[1] || ($(params[0]).val() == params[1] && value != "");
});

!function () {
	var fn = function (value, element, param) {
		return Object.prototype.toString.apply(window[param]) !== "[object Function]" ||
			window[param].call(element, value);
	};
	jQuery.validator.addMethod("fn", fn, "验证失败");
	jQuery.validator.addMethod("fn1", fn, "验证失败");
	jQuery.validator.addMethod("fn2", fn, "验证失败");
	jQuery.validator.addMethod("fn3", fn, "验证失败");
}();
jQuery.validator.addMethod("fnOptional", function (value, element, param) {
	return this.optional(element) || Object.prototype.toString.apply(window[param]) !== "[object Function]" ||
		window[param].call(element, value);
}, "验证失败");

